#include <hxcpp.h>

#ifndef INCLUDED_format_tools_Adler32
#include <format/tools/Adler32.h>
#endif
#ifndef INCLUDED_format_tools__InflateImpl_Window
#include <format/tools/_InflateImpl/Window.h>
#endif
#ifndef INCLUDED_haxe_io_Bytes
#include <haxe/io/Bytes.h>
#endif
namespace format{
namespace tools{
namespace _InflateImpl{

Void Window_obj::__construct(bool hasCrc)
{
{
	HX_SOURCE_POS("/usr/lib/haxe/lib/format/1,22/format/tools/InflateImpl.hx",44)
	this->buffer = ::haxe::io::Bytes_obj::alloc((int)65536);
	HX_SOURCE_POS("/usr/lib/haxe/lib/format/1,22/format/tools/InflateImpl.hx",45)
	this->pos = (int)0;
	HX_SOURCE_POS("/usr/lib/haxe/lib/format/1,22/format/tools/InflateImpl.hx",46)
	if ((hasCrc)){
		HX_SOURCE_POS("/usr/lib/haxe/lib/format/1,22/format/tools/InflateImpl.hx",46)
		this->crc = ::format::tools::Adler32_obj::__new();
	}
}
;
	return null();
}

Window_obj::~Window_obj() { }

Dynamic Window_obj::__CreateEmpty() { return  new Window_obj; }
hx::ObjectPtr< Window_obj > Window_obj::__new(bool hasCrc)
{  hx::ObjectPtr< Window_obj > result = new Window_obj();
	result->__construct(hasCrc);
	return result;}

Dynamic Window_obj::__Create(hx::DynamicArray inArgs)
{  hx::ObjectPtr< Window_obj > result = new Window_obj();
	result->__construct(inArgs[0]);
	return result;}

Void Window_obj::slide( ){
{
		HX_SOURCE_PUSH("Window_obj::slide")
		HX_SOURCE_POS("/usr/lib/haxe/lib/format/1,22/format/tools/InflateImpl.hx",50)
		if (((this->crc != null()))){
			HX_SOURCE_POS("/usr/lib/haxe/lib/format/1,22/format/tools/InflateImpl.hx",50)
			this->crc->update(this->buffer,(int)0,(int)32768);
		}
		HX_SOURCE_POS("/usr/lib/haxe/lib/format/1,22/format/tools/InflateImpl.hx",51)
		::haxe::io::Bytes b = ::haxe::io::Bytes_obj::alloc((int)65536);
		HX_SOURCE_POS("/usr/lib/haxe/lib/format/1,22/format/tools/InflateImpl.hx",52)
		hx::SubEq(this->pos,(int)32768);
		HX_SOURCE_POS("/usr/lib/haxe/lib/format/1,22/format/tools/InflateImpl.hx",53)
		b->blit((int)0,this->buffer,(int)32768,this->pos);
		HX_SOURCE_POS("/usr/lib/haxe/lib/format/1,22/format/tools/InflateImpl.hx",54)
		this->buffer = b;
	}
return null();
}


HX_DEFINE_DYNAMIC_FUNC0(Window_obj,slide,(void))

Void Window_obj::addBytes( ::haxe::io::Bytes b,int p,int len){
{
		HX_SOURCE_PUSH("Window_obj::addBytes")
		HX_SOURCE_POS("/usr/lib/haxe/lib/format/1,22/format/tools/InflateImpl.hx",58)
		if ((((this->pos + len) > (int)65536))){
			HX_SOURCE_POS("/usr/lib/haxe/lib/format/1,22/format/tools/InflateImpl.hx",58)
			this->slide();
		}
		HX_SOURCE_POS("/usr/lib/haxe/lib/format/1,22/format/tools/InflateImpl.hx",59)
		this->buffer->blit(this->pos,b,p,len);
		HX_SOURCE_POS("/usr/lib/haxe/lib/format/1,22/format/tools/InflateImpl.hx",60)
		hx::AddEq(this->pos,len);
	}
return null();
}


HX_DEFINE_DYNAMIC_FUNC3(Window_obj,addBytes,(void))

Void Window_obj::addByte( int c){
{
		HX_SOURCE_PUSH("Window_obj::addByte")
		HX_SOURCE_POS("/usr/lib/haxe/lib/format/1,22/format/tools/InflateImpl.hx",64)
		if (((this->pos == (int)65536))){
			HX_SOURCE_POS("/usr/lib/haxe/lib/format/1,22/format/tools/InflateImpl.hx",64)
			this->slide();
		}
		HX_SOURCE_POS("/usr/lib/haxe/lib/format/1,22/format/tools/InflateImpl.hx",65)
		this->buffer->b[this->pos] = c;
		HX_SOURCE_POS("/usr/lib/haxe/lib/format/1,22/format/tools/InflateImpl.hx",66)
		(this->pos)++;
	}
return null();
}


HX_DEFINE_DYNAMIC_FUNC1(Window_obj,addByte,(void))

int Window_obj::getLastChar( ){
	HX_SOURCE_PUSH("Window_obj::getLastChar")
	HX_SOURCE_POS("/usr/lib/haxe/lib/format/1,22/format/tools/InflateImpl.hx",69)
	return this->buffer->b->__get((this->pos - (int)1));
}


HX_DEFINE_DYNAMIC_FUNC0(Window_obj,getLastChar,return )

int Window_obj::available( ){
	HX_SOURCE_PUSH("Window_obj::available")
	HX_SOURCE_POS("/usr/lib/haxe/lib/format/1,22/format/tools/InflateImpl.hx",73)
	return this->pos;
}


HX_DEFINE_DYNAMIC_FUNC0(Window_obj,available,return )

::format::tools::Adler32 Window_obj::checksum( ){
	HX_SOURCE_PUSH("Window_obj::checksum")
	HX_SOURCE_POS("/usr/lib/haxe/lib/format/1,22/format/tools/InflateImpl.hx",78)
	if (((this->crc != null()))){
		HX_SOURCE_POS("/usr/lib/haxe/lib/format/1,22/format/tools/InflateImpl.hx",78)
		this->crc->update(this->buffer,(int)0,this->pos);
	}
	HX_SOURCE_POS("/usr/lib/haxe/lib/format/1,22/format/tools/InflateImpl.hx",79)
	return this->crc;
}


HX_DEFINE_DYNAMIC_FUNC0(Window_obj,checksum,return )

int Window_obj::SIZE;

int Window_obj::BUFSIZE;


Window_obj::Window_obj()
{
}

void Window_obj::__Mark(HX_MARK_PARAMS)
{
	HX_MARK_BEGIN_CLASS(Window);
	HX_MARK_MEMBER_NAME(buffer,"buffer");
	HX_MARK_MEMBER_NAME(pos,"pos");
	HX_MARK_MEMBER_NAME(crc,"crc");
	HX_MARK_END_CLASS();
}

void Window_obj::__Visit(HX_VISIT_PARAMS)
{
	HX_VISIT_MEMBER_NAME(buffer,"buffer");
	HX_VISIT_MEMBER_NAME(pos,"pos");
	HX_VISIT_MEMBER_NAME(crc,"crc");
}

Dynamic Window_obj::__Field(const ::String &inName,bool inCallProp)
{
	switch(inName.length) {
	case 3:
		if (HX_FIELD_EQ(inName,"pos") ) { return pos; }
		if (HX_FIELD_EQ(inName,"crc") ) { return crc; }
		break;
	case 4:
		if (HX_FIELD_EQ(inName,"SIZE") ) { return SIZE; }
		break;
	case 5:
		if (HX_FIELD_EQ(inName,"slide") ) { return slide_dyn(); }
		break;
	case 6:
		if (HX_FIELD_EQ(inName,"buffer") ) { return buffer; }
		break;
	case 7:
		if (HX_FIELD_EQ(inName,"BUFSIZE") ) { return BUFSIZE; }
		if (HX_FIELD_EQ(inName,"addByte") ) { return addByte_dyn(); }
		break;
	case 8:
		if (HX_FIELD_EQ(inName,"addBytes") ) { return addBytes_dyn(); }
		if (HX_FIELD_EQ(inName,"checksum") ) { return checksum_dyn(); }
		break;
	case 9:
		if (HX_FIELD_EQ(inName,"available") ) { return available_dyn(); }
		break;
	case 11:
		if (HX_FIELD_EQ(inName,"getLastChar") ) { return getLastChar_dyn(); }
	}
	return super::__Field(inName,inCallProp);
}

Dynamic Window_obj::__SetField(const ::String &inName,const Dynamic &inValue,bool inCallProp)
{
	switch(inName.length) {
	case 3:
		if (HX_FIELD_EQ(inName,"pos") ) { pos=inValue.Cast< int >(); return inValue; }
		if (HX_FIELD_EQ(inName,"crc") ) { crc=inValue.Cast< ::format::tools::Adler32 >(); return inValue; }
		break;
	case 4:
		if (HX_FIELD_EQ(inName,"SIZE") ) { SIZE=inValue.Cast< int >(); return inValue; }
		break;
	case 6:
		if (HX_FIELD_EQ(inName,"buffer") ) { buffer=inValue.Cast< ::haxe::io::Bytes >(); return inValue; }
		break;
	case 7:
		if (HX_FIELD_EQ(inName,"BUFSIZE") ) { BUFSIZE=inValue.Cast< int >(); return inValue; }
	}
	return super::__SetField(inName,inValue,inCallProp);
}

void Window_obj::__GetFields(Array< ::String> &outFields)
{
	outFields->push(HX_CSTRING("buffer"));
	outFields->push(HX_CSTRING("pos"));
	outFields->push(HX_CSTRING("crc"));
	super::__GetFields(outFields);
};

static ::String sStaticFields[] = {
	HX_CSTRING("SIZE"),
	HX_CSTRING("BUFSIZE"),
	String(null()) };

static ::String sMemberFields[] = {
	HX_CSTRING("buffer"),
	HX_CSTRING("pos"),
	HX_CSTRING("crc"),
	HX_CSTRING("slide"),
	HX_CSTRING("addBytes"),
	HX_CSTRING("addByte"),
	HX_CSTRING("getLastChar"),
	HX_CSTRING("available"),
	HX_CSTRING("checksum"),
	String(null()) };

static void sMarkStatics(HX_MARK_PARAMS) {
	HX_MARK_MEMBER_NAME(Window_obj::SIZE,"SIZE");
	HX_MARK_MEMBER_NAME(Window_obj::BUFSIZE,"BUFSIZE");
};

static void sVisitStatics(HX_VISIT_PARAMS) {
	HX_VISIT_MEMBER_NAME(Window_obj::__mClass,"__mClass");
	HX_VISIT_MEMBER_NAME(Window_obj::SIZE,"SIZE");
	HX_VISIT_MEMBER_NAME(Window_obj::BUFSIZE,"BUFSIZE");
};

Class Window_obj::__mClass;

void Window_obj::__register()
{
	Static(__mClass) = hx::RegisterClass(HX_CSTRING("format.tools._InflateImpl.Window"), hx::TCanCast< Window_obj> ,sStaticFields,sMemberFields,
	&__CreateEmpty, &__Create,
	&super::__SGetClass(), 0, sMarkStatics, sVisitStatics);
}

void Window_obj::__boot()
{
	hx::Static(SIZE) = (int)32768;
	hx::Static(BUFSIZE) = (int)65536;
}

} // end namespace format
} // end namespace tools
} // end namespace _InflateImpl
